package es.uji.viselab.visualservoing;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import javax.swing.JPanel;

import es.uji.viselab.benchmark.BenchMarkingRecorder;
import es.uji.viselab.experiment.ExperimentParameters;
import es.uji.viselab.image.source.ImageListener;
import es.uji.viselab.image.source.ImageSource;
import es.uji.viselab.model.ModelCreator;
import es.uji.viselab.robot.Robot;
import es.uji.viselab.robot.RobotCatalog;
import es.uji.viselab.robot.RobotListener;

public abstract class  VisualServoingTask implements ImageListener{ 
	
	ExperimentParameters ep;
	double error;
	
	protected Set<VisualServoingListener> notifiers = new HashSet<VisualServoingListener>();

	
	VisualServoingTask(ExperimentParameters ep){
		this.ep=ep;
	}
	
	
	
	public abstract double[] compute(ImageSource image);
	public abstract JPanel getPanel();
	public abstract double getError();

	public void addListener(VisualServoingListener vsl) {
		notifiers.add(vsl);
	}
	
	

	protected void notifyNewPositionRequested(VisualServoingTask vst) {
		Iterator<VisualServoingListener> ivsl = notifiers.iterator();
		while (ivsl.hasNext()) {
			VisualServoingListener vsl = ivsl.next();
			vsl.newPositionRequested(vst);
		}
	}

	
	
	
}
